10. Arrhythmia Detection: Features

Heading

Arrhythmia Detection: Features

ND320 C4 L4 09 AF Detection - Features

Summary

Summary

As with activity classification, we will featurize our raw signal and throw those features into a classifier to detect an abnormal heart rhythm. Our input signal will be the time between two QRS complexes, known as the RR interval (for the R-wave). This is also called the inter-beat-interval. Our input signal will be derived from the output of the Pan-Tompkins algorithm. We will include some of the features in

Behar, Rosenberg, Yaniv, Oster. Rhythm and Quality Classification from Short ECGs Recorded Using a Mobile Device. Computing in Cardiology Challenge 2017.

and

Bonizzi, Driessens, Karel. Detection of Atrial Fibrillation Episodes from Short Single Lead Recordings by Means of Ensemble Learning. Computing in Cardiology Challenge 2017.

which were entries in the CinC challenge. Recall that the RR interval time series is irregularly sampled heartbeat because we get a new measurement at each heartbeat, not at some fixed interval in time. As you’ll soon see, many of the features we want can be computed on an irregular time series, but some, especially frequency domain features, cannot. In that case, we’ll first have to make this uniform using interpolation before we can compute our frequency domain features.

So we can separate our features into time domain features and frequency domain features. The first few are summary statistics like min, max, median, mean, standard deviation. Then we want to compute the number of outliers. And we’ll say an outlier is an RR interval that is greater than 1.2 times the average RR interval in that record.

Next, we want to compute the root-mean-square of the difference between adjacent RR intervals. And lastly, we want the percent of RR interval differences that are greater than 50 milliseconds.

Before we compute our frequency domain features, we will need to regularize the RR interval time series so that we can take the FFT of it. We want to interpolate the RR interval time series onto a regular 4 Hz time grid. Then the features we want will be the largest FFT magnitude component between 0.04 Hz and 0.15 Hz. We also want to know at which frequency this occurs. And we want both of these values for the band between 0.15 Hz and 0.4 Hz as well.

I will leave the feature computation code for you to do in the next exercise and in the next video we will pick this back up with the implementation.

Glossary

  • inter-beat-interval: The time between successive heart beats. Also called the RR interval.

Notebook Review

If you wanted to interact with the notebook in the video, you can access it here in the repo /ecg-processing/walkthroughs/af-features/. It won't be available below because this will be seen as the starter code for the next exercise.

Exercise 2 Intro and Instructions

Exercise 2: AF Features

Instructions

  1. Complete the Offline or Online instructions below.
  2. Read through the whole .ipynb.
  3. Complete all the code cells that contain ## Your Code Goes Here.

Offline

  1. In the repo which you can access here in the repo /ecg-processing/exercises/2-af-features/) you should find the following files:
  • 2_af_features.ipynb
  • l4e1/*.npz
  1. Open up the python notebook and associated files in your desired editor.

Note: Instructions can be found in Introduction to Wearable Data's Concept Developer Workflow for how to set up your local environment.

Online

  1. Go to the next concept and the 2_af_features.ipynb should be open and the workspace should already contain the appropriate data file, l4e1/*.npz.